package com.lihuinch.test.feishu.eventsubscribe.handler.impl;

import com.alibaba.fastjson.JSONObject;
import com.lihuinch.test.feishu.eventsubscribe.constant.TestConstants;
import com.lihuinch.test.feishu.eventsubscribe.handler.FeishuEventHandler;
import com.lihuinch.test.feishu.eventsubscribe.handler.response.FeishuEventContactDepartmentCreatedV3Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * 部门创建事件
 *
 * @author：岳彩郑
 * @desc：TODO
 * @date：2022/9/28 16:05
 **/
@Service(FeishuEventHandler.FEI_SHU_EVENT_HANDLER + "_" + TestConstants.FeishuEvent.Contact.CONTACT_DEPARTMENT_CREATED_V3)
public class FeishuEventContactDepartmentCreatedV3Handler implements FeishuEventHandler<FeishuEventContactDepartmentCreatedV3Response> {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public FeishuEventContactDepartmentCreatedV3Response handleEvent(JSONObject param) {
        logger.info("FeishuEventContactDepartmentCreatedV3Response");
        JSONObject event = param.getJSONObject("event");
        JSONObject DepartmentCreated = event.getJSONObject("object");
        String name = DepartmentCreated.getString("name");
        System.out.println(name);


        return new FeishuEventContactDepartmentCreatedV3Response();
    }
}
